
import 'package:flutter/widgets.dart';
import 'package:oktoast/oktoast.dart';

/// 包装一层吐司 方便统一设置 UI
class ToastUtil {

  static final _shotDuration = Duration(milliseconds: 3000);
  static final _longDuration = Duration(milliseconds: 5000);


  static void showShortToast(String msg) {
    _show(msg, _shotDuration);
  }

  static void showLongToast(String msg) {
    _show(msg, _longDuration);
  }

  /// 弹出吐司
  static void _show(String msg, Duration duration) {

    showToast(
      msg,
      duration: duration,
      textPadding: EdgeInsets.symmetric(vertical: 12, horizontal: 20,),
    );

  }


  static void showShortWidgetToast(Widget widget) {
    _showWidget(widget, _shotDuration);
  }

  static void showLongWidgetToast(Widget widget) {
    _showWidget(widget, _longDuration);
  }

  /// 弹出自定义 widget 吐司
  static void _showWidget(Widget widget, Duration duration){
    showToastWidget(widget, duration: duration);
  }

}